package org.geekbang.thinking.in.spring.generic;

import java.util.ArrayList;
import java.util.Collection;

/**
 * Java 泛型示例
 *
 * @author wangyh2
 * @version v1.0
 * @since 2021-11-26 19:20
 */
public class GeneticDemo {
    public static void main(String[] args) {
        Collection<String> list = new ArrayList<>();
        list.add("hello");
        list.add("world");
        System.out.println(list);

        // 泛型擦写
        Collection tempList = list;
        // 编译通过
        tempList.add(1);
        // 打印报错
        list.forEach(System.out::println);

    }
}
